home *** CD-ROM | disk | FTP | other *** search
- // ==================================================
- // LHelpMenu.cp
- // Copyright (C) 1996 Mizutori Tetsuya, August 4 1996.
- // ==================================================
- // All documents are pretty-printed in Geneva 10-point font.
-
- #include <Menus.h>
- #include <Memory.h>
- #include <Balloons.h>
-
- #include <LMenuBar.h>
- #include <LMenu.h>
- #include <PP_Messages.h>
-
- //#include "touchMeConstants.h"
- #include "LHelpMenu.h"
-
-
- // --------------------------------------------------
- // ・ LHelpMenu
- // --------------------------------------------------
-
- LHelpMenu::LHelpMenu()
- {
- OSErr err;
-
- mMENUid = kHMHelpMenuID; // -16490
- mNextMenu = nil; // set by the procedure 'LMenuBar::InstallMenu()'
- mNumCommands = 0; // the number of items in this menu
- mCommandNums = nil; // handle to the array of CommandT[*]
- mIsInstalled = false; // set by the procedure 'LMenuBar::InstallMenu()'
- mUsed = false; // set by the procedure 'LEventDispatcher::UpdateMenus()'
- mMacMenuH = nil; // Macintosh Toolbox menu handle
-
- // Get the help menu handle, which belongs to my application.
- // Do not call ::GetMenuHandle( kHMHelpMenuID ) to get the handle.
- err = ::HMGetHelpMenuHandle( &mMacMenuH );
- // The old MacOS has no HelpMenu, so it returns to do nothing.
- if ( err != noErr ) return;
-
- // Setup a command table of this LHelpMenu object.
- mNumCommands = ::CountMItems( mMacMenuH );
- if ( mNumCommands > 0) {
- Int32 commandsSize = mNumCommands * sizeof(Int32);
- // All the value of (*mCommandNums)[k] are to be 'cmd_Nothing'(= 0).
- mCommandNums = (CommandT **) ::NewHandleClear( commandsSize );
- }
- }
-
-
- // --------------------------------------------------
- // ・ ~LHelpMenu
- // --------------------------------------------------
-
- LHelpMenu::~LHelpMenu()
- {
- }
-
-
- // --------------------------------------------------
- // ・ InstallMenu
- // --------------------------------------------------
-
- void
- LHelpMenu::InstallMenu(
- LMenuBar *inMenuBar )
- {
- if ( IsInstalled() ) return;
-
- // If the MacOS has already a Help Menu in the MenuBar,
- // then 'LMenuBar::InstallMenu()' does not do nothing for '::InsertMenu()',
- // but updates the LHelpMenu status of 'mNextMenu' and 'mIsInstalled'.
-
- // LMenuBar * theMenuBar = (LMenuBar *) LMenuBar::GetCurrentMenuBar();
- inMenuBar->InstallMenu( (LMenu *)this, InstallMenu_AtEnd );
- }
-
-
- // --------------------------------------------------
- // ・ EnableItem
- // --------------------------------------------------
-
- void
- LHelpMenu::EnableItem()
- {
- // The PowerPlant seems to neglect the Help Menu. So you must update
- // the menu status to be enabled after 'LEventDispatcher::UpdateMenus()'.
-
- // Enable the title of the Help Menu in the MenuBar.
- ::EnableItem( mMacMenuH, 0 );
-
- // Enable all the items of the Help Menu.
- for ( short i=1; i<=mNumCommands; i++ ) ::EnableItem( mMacMenuH, i );
-
- // This menu should be considered "used" to be enabled.
- SetUsed( true );
- }
-
- // end of program
-